home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-2.iso / extra_2 / nadir11.zip / TYPE.N < prev    next >
Text File  |  1995-11-08  |  4KB  |  146 lines

  1. If(0)
  2.     This module generates the code for the Valuation and Property Type
  3.     description files.
  4.  
  5.     This data is stored in the UNIV file
  6.  
  7.     code is the property type code or valuation type code
  8.  
  9.     ptyp_code^[code]  = description for property type
  10.     vtyp_code^[code]  = description for valuation type
  11.  
  12. Endif
  13. Define DescSearchCode(Desc, desc)
  14. /*
  15.     Desc is Vtyp or Ptyp etc
  16.     desc is vtyp or ptyp etc
  17.  
  18.     This will generate the formatting routine for the combo box
  19. */
  20. {
  21.     Print(`
  22. Define `><Desc><`SearchCode(key, type) {
  23.     Explode(key, "^", &code);
  24.     if (type != "s")
  25.         return code;
  26.     return StrCat(code, "\t", univ^`><desc><`_code^[code]);
  27. }`);
  28. }
  29. Define DescMaintScr(Desc, desc, nameLong, nameAbrv)
  30. /*
  31.     This will generate the code that defines the Screen Dialogue
  32. */
  33. {
  34.     Print(`
  35. Define `><Desc><`MaintScr() {
  36.     scr = SdCreate(, -1, -1, 18, 72, "`><nameLong><` Maintenance");
  37.  
  38.     SdPrompt(scr, 1,  1, "`><nameAbrv><` Code  :");
  39.     SdCombo(scr, "code",  0,  1, 19, 12, 10, "", "univ^`><desc><`_code^", 133, 
  40.                                            "`><Desc><`SearchCode", 62, , 134);
  41.     SdFieldCols(scr, "code", 10);
  42.     SdPrompt(scr, 3,  1, "`><nameAbrv><` Name  :");
  43.     SdString(scr, "desc", 0,  3, 19, 50);
  44.  
  45.     SdButton(scr, "ok",   0, 16, 29, 10, "Maint", "m", 1);
  46.     SdButton(scr, "del",  0, 16, 42, 10, "Delete", "d", 114);
  47.     SdButton(scr, "can",  1, 16, 55, 10, "Cancel", "", 2);
  48.     return scr;
  49. }`);
  50. }
  51. Define DescDelete(Desc, desc)
  52. /*
  53.     This will generate the code that deletes one of the descriptions
  54. */
  55. {
  56.     Print(`
  57. Define `><Desc><`Delete(code) {
  58.     while(field = NextField("univ", "`><desc><`", code, field))
  59.         univ^`><desc><`^[code]^[field] = "";
  60.     univ^`><desc><`_code^[code] = "";
  61. }`);
  62. }
  63. Define DescMaint(Desc, desc, nameLong)
  64. /*
  65.     This will generate the code that maintains a description
  66. */
  67. {
  68.     Print(`
  69. Define `><Desc><`Maint() {
  70.     scr = `><Desc><`MaintScr();
  71.     mode = 1;
  72.     cursor = "";
  73.     while (1) {
  74.         if (!cursor) {
  75.             if (mode) {
  76.                 SdModeSet(scr, 0);
  77.                 SdModeSet(scr, 1, "code", "del", "can");
  78.                 SdButton(scr, "ok",   1, 16, 29, 10, "Maint", "m", 1);
  79.             }
  80.             else {
  81.                 SdModeSet(scr, 1);
  82.                 SdModeSet(scr, 0, "code", "del");
  83.                 if (univ^`><desc><`_code^[code])
  84.                     SdButton(scr, "ok",   1, 16, 29, 10, "Modify", "m", 1);
  85.                 else
  86.                     SdButton(scr, "ok",   1, 16, 29, 10, "Add", "a", 1);
  87.             }
  88.             SdFieldVar(scr, "code",     code,
  89.                             "desc",        &univ^`><desc><`_code^[code]);
  90.         }
  91.         cmd = SdEdit(scr, cursor);
  92.         if (mode) {
  93.             Explode(SdFieldGet(scr, "code"), "^", &code);
  94.             if (cmd == 133)                /* action on the combo box */
  95.                 continue;
  96.             else if (cmd == 2 || cmd == 3)
  97.                 break;
  98.             else if (cmd != 1 && cmd != 134) {
  99.                 if (!univ^`><desc><`_code^[code]) {
  100.                     MsgWait("", "`><nameLong><` Code does not exist.");
  101.                     continue;
  102.                 }
  103.                 if (cmd == 114) {        /* delete */
  104.                     if ((cmd = MsgYesNoCancel("", "Delete " . code . ", are you sure ?")) && cmd == 2) {        /* yes hit ? */
  105.                         `><Desc><`Delete(code);
  106.                     }
  107.                 }
  108.                 continue;
  109.             }
  110.             mode = 0;                    /* means change details */
  111.         }
  112.         else {
  113.             if (cmd == 1) {
  114.                 if (!SdFieldGet(scr, "desc")) {
  115.                     MsgWait("", "`><nameLong><` Name must be entered.");
  116.                     cursor = "desc";
  117.                     continue;
  118.                 }
  119.                 SdUpdate(scr);
  120.             }
  121.             else if (cmd == 3) 
  122.                 break;
  123.             mode = 1;                    /* means do next selection */
  124.         }
  125.         cursor = "";
  126.     }
  127.     SdDestroy(scr);
  128. }`);
  129. }
  130. Define DescGenerate(Desc, desc, nameLong, nameAbrv)
  131. {
  132.     DescSearchCode(Desc, desc);
  133.     DescMaintScr(Desc, desc, nameLong, nameAbrv);
  134.     DescDelete(Desc, desc);
  135.     DescMaint(Desc, desc, nameLong);
  136. }
  137. Eval {
  138. /*
  139.     When this is evaluated, the code for the Property Type Maintenance
  140.     program, and the Valuation Type Maintenance program is output
  141.     using the macros that we have just defined.
  142. */
  143.     DescGenerate("Ptyp", "ptyp", "Property Type", "Prop Type");
  144.     DescGenerate("Vtyp", "vtyp", "Valuation Type", "Valn Type");
  145. }
  146.